package com.magictower.primary.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.magictower.primary.R;
import com.magictower.primary.common.SPConstant;


/**
 * Created by kejunzhan on 2017/12/7.
 */

public class Setup4Activity extends BaseSetupActivity {

    private CheckBox cbProtect;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setup4);

        cbProtect = (CheckBox) findViewById(R.id.cb_protect);
        boolean aBoolean = mPref.getBoolean(SPConstant.SAFE_PROTECT, false);
        if (aBoolean) {
            cbProtect.setChecked(true);
            cbProtect.setText("防盗保护已经开启");
        } else {
            cbProtect.setChecked(false);
            cbProtect.setText("防盗保护没有开启");
        }

        cbProtect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    cbProtect.setText("防盗保护开启");
                    mPref.edit().putBoolean(SPConstant.SAFE_PROTECT, true).apply();
                } else {
                    cbProtect.setText("防盗保护关闭");
                    mPref.edit().putBoolean(SPConstant.SAFE_PROTECT, false).apply();
                }
            }
        });
    }

    @Override
    public void showNextPage() {
        startActivity(new Intent(Setup4Activity.this, LostFindActivity.class));
        finish();
        overridePendingTransition(R.anim.page_alpha_in, R.anim.page_tran_out);
    }

    @Override
    public void showPreviousPage() {
        startActivity(new Intent(Setup4Activity.this, Setup3Activity.class));
        finish();
        overridePendingTransition(R.anim.page_tran_in, R.anim.page_alpha_out);
    }

}
